package com.neusoft.chess;

import java.awt.*;
import java.util.Map;

/**
 * @Author: duan
 * @Date: Create in 14:30 2020/9/28
 */
public class PaoChess extends Chess {
    public PaoChess(int px, int player) {
        super("pao", new Point(px, 3), player);
    }

    @Override
    public boolean isAbleMove(Point t, Map<Point, Chess> map) {
        if (isLine(t) < 3) {
            return false;
        }
        Chess c = map.get(t);
        if (c == null) {
            //移动，中间不能有棋子挡住
            return getChessCount(t, map) == 0;
        } else {
            //吃子，有且只有一个跑台
            return getChessCount(t, map) == 1;
        }
    }
}
